package com.cmw.auntapp.core.util;

import android.os.Environment;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class EnvironmentShare {
    static String path = new SimpleDateFormat("yyyy/MM/dd").format(new Date());
    public final static String APP_AINSTALL_DIR = getSdCardAbsolutePath() + File.separator + "com.cmw.auntapp";
    public final static String FILE = APP_AINSTALL_DIR + File.separator + "file";
    public final static String APK = APP_AINSTALL_DIR + File.separator + "apk";
    public final static String SHAREORDER_URL = APP_AINSTALL_DIR + "/shareorder";//晒单
    public final static String WATERPULL_URL = APP_AINSTALL_DIR + "/waterpull";//瀑布流
    public final static String CACHE_URL = APP_AINSTALL_DIR + "/cache";
    public static final String MSG_FILE_URL = APP_AINSTALL_DIR + "/msg/file";
    public static final String PRINTSCREEN_URL = APP_AINSTALL_DIR + "/printscreen";
    public static final String TEMP_URL = APP_AINSTALL_DIR + "/temp";
    public static final String KB_URL = APP_AINSTALL_DIR + "/kb";
    public final static String PERSONAL_PHOTO = APP_AINSTALL_DIR + "/personal/photo";
    public final static String CAPTURED_FACE_IMG = APP_AINSTALL_DIR + "/captured/face";

    public final static String HEALTH_HB = APP_AINSTALL_DIR + "/health/hb";
    public final static String HEALTH_T = APP_AINSTALL_DIR + "/health/t";
    public final static String HEALTH_TH = APP_AINSTALL_DIR + "/health/th";
    public final static String DEVICE_QR = APP_AINSTALL_DIR + "/device/qr";
    public final static String HEALTH_RAW = APP_AINSTALL_DIR + "/health/raw";

    public static final String USER_IMAGE = getSdCardAbsolutePath()
            + "/DCIM/Camera";

    public static final String LOG_DIR = APP_AINSTALL_DIR + "/log";

    public static final String DOWNLOAD_DIR = APP_AINSTALL_DIR + "/download";
    // 存放下载而来的录音文件夹名称

    /**
     * 检测当前设备SD是否可用
     *
     * @return 返回"true"表示可用，否则不可用
     */
    public static boolean haveSdCard() {
        return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
    }

    /**
     * 获得SD卡根目录路径
     *
     * @return String类型  SD卡根目录路径
     */
    public static String getSdCardAbsolutePath() {
        return Environment.getExternalStorageDirectory().getAbsolutePath();
    }

    /*
    * 抓拍到的人脸*/
    public static File getCapturedFace() {
        File filePath = new File(CAPTURED_FACE_IMG);
        if (!filePath.exists()) {
            filePath.mkdirs();
        }
        return filePath;
    }

    public static File getDeviceQR() {
        File filePath = new File(DEVICE_QR);
        if (!filePath.exists()) {
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 日志目录
     */
    public static File getLogDir() {
        File filePath = new File(LOG_DIR);
        if (!filePath.exists()) {
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 健康数据原始数据
     */
    public static File getHealthRaw() {
        File filePath = new File(HEALTH_RAW);
        if (!filePath.exists()) {
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 将康数据-心率、呼吸
     */
    public static File getHealthHBFileDir() {
        File filePath = new File(HEALTH_HB);
        if (!filePath.exists()) {
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 将康数据-体温
     */
    public static File getHealthTFileDir() {
        File filePath = new File(HEALTH_T);
        if (!filePath.exists()) {
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 将康数据-体温
     */
    public static File getHealthTHFileDir() {
        File filePath = new File(HEALTH_TH);
        if (!filePath.exists()) {
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 获得更新版本的文件夹
     *
     * @return File类型
     * 存放更新apk文件的文件夹
     */
    public static File getAPKFileDir() {
        File filePath = new File(APK);
        if (!filePath.exists()) {
            // 此处可能会创建失败，暂不考虑
            filePath.mkdirs();
        }
        return filePath;
    }

    public static File getUserImg() {
        File filePath = new File(USER_IMAGE);
        if (!filePath.exists()) {
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 获得瀑布流 的文件夹
     *
     * @return File类型
     * 存放更新apk文件的文件夹
     */
    public static File getWaterpullFileDir() {
        File filePath = new File(WATERPULL_URL);
        if (!filePath.exists()) {
            // 此处可能会创建失败，暂不考虑
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 获得 晒单的文件夹
     *
     * @return File类型
     */
    public static File getShareOrderFileDir() {
        File filePath = new File(SHAREORDER_URL);
        if (!filePath.exists()) {
            // 此处可能会创建失败，暂不考虑
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 获得附件的文件夹
     *
     * @return File类型
     * 附件文件的文件夹
     */
    public static File getDownLoadFileDir() {
        File filePath = new File(FILE);
        if (!filePath.exists()) {
            // 此处可能会创建失败，暂不考虑
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 获得临时的文件夹
     *
     * @return File类型
     * 头像文件的文件夹
     */
    public static File getFileTemp() {
        File filePath = new File(TEMP_URL);
        if (!filePath.exists()) {
            // 此处可能会创建失败，暂不考虑
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 获得知识库的文件夹
     *
     * @return File类型
     * 头像文件的文件夹
     */
    public static File getFileKB() {
        File filePath = new File(KB_URL);
        if (!filePath.exists()) {
            // 此处可能会创建失败，暂不考虑
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * @return File类型
     * 头像文件的文件夹
     */
    public static File getPersonalPhoto() {
        File filePath = new File(PERSONAL_PHOTO);
        if (!filePath.exists()) {
            // 此处可能会创建失败，暂不考虑
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 获得shop根目录
     */
    public static File getShopFile() {
        File filePath = new File(APP_AINSTALL_DIR);
        if (!filePath.exists()) {
            // 此处可能会创建失败，暂不考虑
            filePath.mkdirs();
        }
        return filePath;
    }

    /**
     * 获得截图文件夹
     *
     * @return 图片类型
     */
    public static File getPrintScreenURL() {
        File filePath = new File(PRINTSCREEN_URL);
        if (!filePath.exists()) {
            // 此处可能会创建失败，暂不考虑
            filePath.mkdirs();
        }
        return filePath;
    }


}
